<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = &get_instance();
	$this->load->helper('captcha');
	
?>
<form action="<?php echo site_url('cricket/user/login');?>" name="login" id="login" method="post" enctype="multipart/form-data" >
	<div id="center_content">
		<div class="clrboth"></div>
		<div class="block">
			<div class="title"><h3 class="bold">User Login</h3></div>
			<div class="clrboth"></div>
			<div class="content">
				<div class="rowitem3" style="position:relative;padding-left:10px;margin-top:0px;min-height:250px;">
				<div style="position:absolute;left:100px;" id="regis_form">
					<div class="grid2"><span class="bold">*Username:</span></div>
					<div class="grid6"><input type="text" maxlength="45" id="username" name="username" class="std-input"/></div>
					<div class="grid2"><span class="bold red hidden" id="username_error">Required field.</span></div>
					
					<div class="clrboth"></div>
					
					<div class="grid2"><span class="bold">*Password:</span></div>
					<div class="grid6"><input type="password" maxlength="45" id="password" name="password" class="std-input"/></div>
					<div class="grid2"><span class="bold red hidden" id="password_error">Required field.</span></div>
					
					<div class="clrboth"></div>
					<div class="grid2">&nbsp;</div>
					<div class="grid6" style="margin-bottom:5px;padding-left:5px;">
						<a href="<?php echo site_url("cricket/user/forgot_details"); ?>" id="forgot_details" style="color:#333333;text-decoration:none;">Forgot details</a>
					</div>
					
					
					<div class="clrboth"></div>
					<div class="grid2">&nbsp;</div>
					<div class="grid6"><input type="submit" class="submitclass" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
					
					<div class="clrboth"></div>	
					
					<div class="grid2">&nbsp;</div>
					<div class="grid6" id="system_error"></div>

					<div class="clrboth"></div>		
				
				<div class="clrboth"></div>
				</div>	
			</div>
			</div>
		</div>	
		<div class="clrboth"></div>
	</div>	
</form> 

<script type="text/javascript">
	google.setOnLoadCallback(function() {
		var option = { 
			beforeSubmit:  validateBeforeSubmit,  
			success: processAfterSubmit
		};	
		$('#login').ajaxForm(option);
	});
	
	function validateBeforeSubmit(formData, jqForm, options){
		$('#loader_image').show();
		$('#system_error').hide();
		return true;
	}
	
	function processAfterSubmit(responseText, statusText, xhr, $form){
		$('#loader_image').hide();
		if(responseText != 'ok'){
			$('#system_error').html(responseText).show();
		}else if(responseText == 'ok'){
			queryURL(BASE_URI+MODULE);
		}
	}
</script>